<template>
	<view style="padding:40rpx;">
		<view v-if="error==0">
			<u-loadmore loadmoreText="加载中..." status="loading" style="margin:100rpx;" v-if="dataLoading==true" />
			<view v-else>
				<u-divider text="单位信息"></u-divider>
				<view class="lable-item">
					<view class="lable-name">单位名称</view>
					<view class="lable-val">{{data.company}}</view>
				</view>
				<view class="lable-item">
					<view class="lable-name">单位税号</view>
					<view class="lable-val">{{data.tax_id}}</view>
				</view>
				<u-divider text="单位信息"></u-divider>

				<view class="lable-item">
					<view class="lable-name">产品名称</view>
					<view class="lable-val">{{data.product_name}}</view>
				</view>
				<view class="lable-item">
					<view class="lable-name">份数</view>
					<view class="lable-val">{{data.num}}</view>
				</view>
				<view class="lable-item">
					<view class="lable-name">单价</view>
					<view class="lable-val">{{data.price}}</view>
				</view>

				<view class="lable-item">
					<view class="lable-name">订单总金额</view>
					<view class="lable-val">{{data.amount}}</view>
				</view>

				<view class="lable-item">
					<view class="lable-name">开始日期</view>
					<view class="lable-val">{{data.starttime}}</view>
				</view>

				<view class="lable-item">
					<view class="lable-name">结束日期</view>
					<view class="lable-val">{{data.endtime}}</view>
				</view>

				<u-divider text="发票信息"></u-divider>
				<view class="lable-item">
					<view class="lable-name">发票类型</view>
					<view class="lable-val">{{data.invoice_type}}</view>
				</view>

				<view class="lable-item">
					<view class="lable-name">收票邮箱</view>
					<view class="lable-val">{{data.invoice_email}}</view>
				</view>

				<view class="lable-item">
					<view class="lable-name">发票备注</view>
					<view class="lable-val">{{data.invoice_remark}}</view>
				</view>

				<view class="lable-item">
					<view class="lable-name">发票要求</view>
					<view class="lable-val">{{data.invoice_desc}}</view>
				</view>

				<u-divider text="地址信息"></u-divider>
				<view class="address_card">
					<view v-for="(item,idx) in  data.order_address" style="border-bottom:1px solid #eee;padding:10rpx 0;">
						<view class="lable-item nomtop">
							<view class="lable-name">姓名</view>
							<view class="lable-val">{{item.name}}</view>
						</view>
						<view class="lable-item nomtop">
							<view class="lable-name">电话</view>
							<view class="lable-val">{{item.mobile}}</view>
						</view>
						<view class="lable-item nomtop">
							<view class="lable-name">份数</view>
							<view class="lable-val">{{item.num}}</view>
						</view>
						<view class="lable-item nomtop">
							<view class="lable-name">邮编</view>
							<view class="lable-val">{{item.code}}</view>
						</view>
						<view class="lable-item nomtop">
							<view class="lable-name">地址</view>
							<view class="lable-val">{{item.address}}</view>
						</view>
						
					</view>
				</view>


			</view>
		</view>
		<view v-else>

		</view>
		<view class="add" @click="editOrder">编辑</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	import {
		getOrderByid
	} from 'config/api.js';
	export default {
		data() {
			return {
				dataLoading: true,
				id: 0,
				error: 0,
				data: []
			}
		},

		computed: {
			...mapState(['hasLogin', 'userInfo']),
		},
		onLoad(options) {
			if (!options.id) {
				this.error = 1;
			}
			this.id = options.id
			this.getData()
		},
		methods: {
			editOrder(){
				uni.navigateTo({
					url: '/pages/index/addOrder?type=edit&id='+this.id
				})
			},
			getData() {
				getOrderByid({
					id: this.id
				}).then(r => {
					this.dataLoading = false
					if (r.data.id) {
						this.data = r.data
					}
				})
			}
		}
	}
</script>

<style>
	page {
		background-color: #fff;
	}
.add {
		background-color: #3c9cff;
		text-align: center;
		color: #fff;
		font-size: 38rpx;
		border-radius: 40rpx;
		padding: 20rpx 50rpx;
		box-shadow: 0 0 10px #3c9cff;
		margin:0 auto;
	}
	.address_card {
		background-color: #f3f3f3;
		border-radius: 10rpx;
		padding: 30rpx;
		margin-bottom: 20rpx;
	}

	.lable-item {
		display: flex;
		flex-wrap: wrap;
		font-size: 30rpx;
		margin-top: 15rpx;

		&.nomtop {
			
			margin: 0;
			margin:10rpx 0;
			.lable-name {
				width:80rpx;
				
			}
		}

		.lable-name {
			color: #999;
			width: 160rpx;
			text-align: right;
		}

		.lable-val {
			width: calc(100% - 190rpx);
			margin-left: 30rpx;
			color: #000;

			&.blue {
				color: #3c9cff
			}

			span {
				color: #999;
				font-weight: normal;
				margin-left: 20rpx;
			}
		}
	}
</style>